<template>
  <basic-container>
    <div>
      <m-s-search @searchClick="v=>{queryForm=v,page.currentPage=1,getList()}" :list="LifeCycleOption.column"></m-s-search>
    </div>
    <avue-crud :option="LifeCycleOption"
               :table-loading="loading"
               :data="data"
               @selection-change="v=>selection=v"
               @current-change="currentChange"
               @size-change="sizeChange"
               ref="crud"
               :page.sync="page">
      <template slot="menuLeft" slot-scope="{size}">
        <el-button :size="size" type="primary"
                   @click="addToTabsList('生命周期规则',{id:-1},'LifeCycleTemp','open')">
          创建
        </el-button>
        <el-button :size="size" :disabled="selection.length===0" @click="remove(selection)">删除
        </el-button>
        <el-button :size="size" :disabled="selection.length===0"
                   @click="start_stop(selection,'start')">
          启用
        </el-button>
        <el-button :size="size" :disabled="selection.length===0"
                   @click="start_stop(selection,'stop')">
          停用
        </el-button>
      </template>

      <template slot="nameCn" slot-scope="{row}">
                <span class="column-btn"
                      @click="addToTabsList(row.nameCn+'生命周期规则',row,'LifeCycleTemp','view')">
                  {{ row.nameCn }}
                </span>
      </template>
      <template slot="menu" slot-scope="{row}">
        <el-button type="text"
                   @click="addToTabsList(row.nameCn+'生命周期规则',row,'LifeCycleTemp','view')">
          查看详情
        </el-button>
        <el-button type="text"
                   @click="addToTabsList(row.nameCn+'生命周期规则',row,'LifeCycleTemp','edit')">
          修改
        </el-button>
        <el-button type="text" :disabled="row.checkState === 1" @click="checkIn(row)">检入</el-button>
        <el-button type="text" :disabled="row.checkState === 1" @click="unCheckOut(row)">撤销检出
        </el-button>
        <el-button type="text"
                   @click="addToTabsList(row.nameCn+'生命周期历史',
                   {...row,...other__,...{params_:{masterOid:row.masterOid}}},
                   'commonHistory','show')">
          历史
        </el-button>
      </template>
    </avue-crud>

    <ms-drawer idKey="id" @refresh="getList()" ref="md" :visible.sync="visible"
               :tab-list.sync="tabsList"></ms-drawer>
  </basic-container>
</template>
<script>
import MSSearch from "@/DMDComponents/MSSearch.vue";
import commonJs from "@/util/commonJs";

export default {
  name: "LifeCycle",
  components: {MSSearch},
  inject: ["LifeCycleOption"],
  mixins: [commonJs],
  data() {
    return {
      other__: {
        url: '/api/state-api/life-cycle/historyList',
        option: this.LifeCycleOption,
        method: "get",
        requestDataType: "params",
      }
    }
  }
}
</script>
